/**
 * 导入资源的js
 */
layui.use(['icheck','element',"laytpl",'laypage','form','laydate'], function() {
	
	var $ = layui.jquery,
    	layer = layui.layer,
    	laytpl = layui.laytpl,
    	laypage = layui.laypage;
    var form = layui.form();
    
    
    //读取页面的提示信息并展示
    var successlog = $("#successlog").val();
    if (successlog != null && successlog.length > 0) {
    	var html = "<div style='margin-top:10px;margin-left:15px;'><p>" + successlog + "</p></div>"
    	layer.open({
    		type: 1, 
    		title : "资源导入结果",
    		content: html, 
    		shadeClose:false,
    		area: ['40%','90%'],
    	});
    }
    
    
    //点击导入资源按钮
    $(".insertbtn").on("click",function(){
    	var count=0;
    	var type = $(this).attr("typedata");
    	var title;
    	if (type == 0) {
    		title = "导入人才资源";
    	} else {
    		title = "导入企业资源";
    	}
 	    	layer.open({
	            title:title,
	            type:1, 
	            content:$('#insertdiv'),
	            btn: ['导入资源', '取消'],
	            shadeClose:false,
	            scrollbar:true,
	            btnAlign:'c',
	            area: ['40%','30%'],
	            yes: function(){
	            	
	            	
	            	var file = $("#file").val();
	            	if (file == null) {
	            		layer.msg("请先上传需要导入的资源");
	            		return false;
	            	} else {
	            		layer.msg('正在上传,请稍等', {
	            			  icon: 16
	            			  ,shade: 0.01
	            			  ,time:0
	            		  });
	            		if(count>0){
	            			 
	            			return false;
	            		}
	            		count++;
	            		$("#insertform").submit();
	            	}
	            }
	        });
    });
	
	
	
	
	
});